import java.io.IOException;
import java.io.Serializable;

/**
 * contains all of the visual components behind a game of MULE
 * 
 * @author Srinidhi Chaganty
 *
 */
public class GameView implements Serializable {
	
	private static GameView instance = new GameView(); //the instance of GameView
	private ConfigurationScreen config; //the instance of ConfigurationScreen
	private SelectionPhase selectionPhase; //the instance of SelectionPhase
	private PlayerGUI playerGUI; //the instance of PlayerGUI
	private MainScreen main; //the instance of MainScreen
	private boolean selectionEnded; //the boolean so whether or not selectionphase ends

	/**
	 * The general no-args constructor for GameView
	 * @throws IOException 
	 */
	public GameView(){
		config = new ConfigurationScreen();
		try {
			playerGUI = new PlayerGUI();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		selectionPhase = new SelectionPhase();
	}
	
	public void setMainScreen() {
		main = new MainScreen();
	}
	
	/**
	 * Returns the instance of GameView
	 * @return GameView instance of GameView
	 */
	public static GameView getInstance(){ 
		return instance;
	}
	
	/**
	 * gets the configuration screen
	 * @return the configuration screen
	 */
	public ConfigurationScreen getConfig(){
		return config;
	}
	
	/**
	 * sets the configuration screen
	 * @param nConfig what to set the configuration screen to
	 */
	public void setConfig(ConfigurationScreen nConfig){
		config = nConfig;
	}

	/**
	 * gets the selection phase
	 * @return the selection phase
	 */
	public SelectionPhase getSelectionPhase() {
		return selectionPhase;
	}
	
	/**
	 * sets the selection phase
	 * @param selectionPhase the selection phase to set to
	 */
	public void setSelectionPhase(SelectionPhase selectionPhase) {
		this.selectionPhase = selectionPhase;
	}

	/**
	 * gets the player gui
	 * @return the player gui
	 */
	public PlayerGUI getPlayerGUI() {
		return playerGUI;
	}

	/**
	 * sets the player gui
	 * @param playerGUI the player gui to be set to
	 */
	public void setPlayerGUI(PlayerGUI playerGUI) {
		this.playerGUI = playerGUI;
	}

	/**
	 * gets the main screen
	 * @return the main screen
	 */
	public MainScreen getMain() {
		return main;
	}

	/**
	 * sets the main screen
	 * @param main the main screen to be set to
	 */
	public void setMain(MainScreen main) {
		this.main = main;
	}

	/**
	 * returns whether or not selection phase has ended
	 * @return whether or not selection phase has ended
	 */
	public boolean isSelectionEnded() {
		return selectionEnded;
	}

	/**
	 * sets whether or not the selection phase has ended
	 * @param selectionEnded true if selection phase ended, false if not
	 */
	public void setSelectionEnded(boolean selectionEnded) {
		this.selectionEnded = selectionEnded;
	}
	
	/*
	 * updates the main screen
	 */
	public void updateMain(){
		main = new MainScreen();
	}
}



